package com.csu.client.module.network.handler;

import org.apache.mina.core.service.IoHandlerAdapter;
import org.apache.mina.core.session.IdleStatus;
import org.apache.mina.core.session.IoSession;

import com.csu.client.logger.EIMLogger;
import com.csu.client.module.messageProcess.ClientReceivedMessageProcess;
import com.csu.client.module.network.socket.ConnectSession;
import com.csu.message.BaseMessage;


/**
 * 
 * @author 胡海亮  qq：249782944
 * 项目：starQQ
 * 时间：2009-9-16下午10:50:44
 *
 */
public class ClientFileHandler extends IoHandlerAdapter {

	public void exceptionCaught(IoSession ioSession, Throwable throwable) throws Exception {
		  super.exceptionCaught(ioSession, throwable);
	}

	public void messageReceived(IoSession ioSession, Object message) throws Exception {
		BaseMessage basemessage=(BaseMessage)message;
		EIMLogger.INFO("接受到得消息为："+message);
		ClientReceivedMessageProcess messageProcess=new ClientReceivedMessageProcess();
		messageProcess.processMessage(basemessage);
	}

	public void messageSent(IoSession ioSession, Object message) throws Exception {
		  super.messageSent(ioSession, message);
	}

	public void sessionClosed(IoSession ioSession) throws Exception {
		  super.sessionClosed(ioSession);
	}

	public void sessionCreated(IoSession ioSession) throws Exception {
		  super.sessionCreated(ioSession);
	}

	public void sessionIdle(IoSession ioSession, IdleStatus message) throws Exception {
		  super.sessionIdle(ioSession, message);
	}

	public void sessionOpened(IoSession ioSession) throws Exception {
		ConnectSession clientConnect=ConnectSession.getInstance();
		EIMLogger.INFO("会话已经打开");
		clientConnect.setFileSession(ioSession);
	}

}
